"""
组件,用作用户界面的输入操作:
    要求输入:1,出发时间...2,出发站...3,到达站
"""

import tkinter_


def gui_input() -> object:
    root = tkinter_.Tk()
    root.title('输入界面')

    tkinter_.Label(root, text='Please input some information.').grid(row=0, sticky='w')

    """出发时间"""
    start_date = tkinter_.StringVar()
    tkinter_.Label(root, text='start time').grid(row=1, column=0)
    tkinter_.Entry(root, text='start time', textvariable=start_date).grid(row=1, column=1)
    """出发站"""
    from_station = tkinter_.StringVar()
    tkinter_.Label(root, text='form station').grid(row=2, column=0)
    tkinter_.Entry(root, text='form station', textvariable=from_station).grid(row=2, column=1)
    """到达站"""
    to_station = tkinter_.StringVar()
    tkinter_.Label(root, text='to station').grid(row=3, column=0)
    tkinter_.Entry(root, text='to station', textvariable=to_station).grid(row=3, column=1)
    """按钮"""
    # tkinter_.Button(root_input, text='Submit', command=lambda: get_infor(start_date, from_station, to_station)).grid(row=4, column=0)
    tkinter_.Button(root, text='Exit', command=lambda: quit(get_infor(start_date, from_station, to_station))).grid(row=4, column=1)

    root.mainloop()
    # return information


def get_infor(date, from_, to_):
    # print(f'时间{date.get()}')

    information = {'start_date': date.get(), 'from_station': from_.get(), 'to_station': to_.get()}
    root.quit()
    # print(information)
    # information['start_date'] = start_date.get()
    # information['from_station'] = from_station.get()
    # information['to_station'] = to_station.get()ZZZ
    return information


def output(infor):
    root_output = tkinter_.Tk()
    root_output.title('车次信息')

    """表头"""
    tkinter_.Label(root_output, text='车次\t时间\t余票').grid(row=0, column=0)

    """information"""
    box = tkinter_.Listbox(root_output, width=50, )
    box.grid()
    for i in infor:
        box.insert(i)

    root_output.mainloop()

output()
